![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
snabbdom-selector
Advanced tools
snabbdom-selector
is a utility tool, written in TypeScript,
to find snabbdom VNode objects matching a given CSS Selector.
npm install snabbdom-selector
import { select } from 'snabbdom-selector'
import * as h from 'snabbdom/h'
const vNode = h('div', {}, [
h('div.test', {}, [
h('p', {key: 1}, 'Foo')
])
])
const matches = select('.test p', vNode)
console.log(matches)
// => [{sel: 'p', text: 'Foo', elm: HTMLElement, key: 1, children: undefined, data: {...}}]
select(cssSelector: string, vNode: snabbdom.VNode): Array<snabbdom.VNode>
select(cssSelector: string): (vNode: snabbdom.VNode) => Array<snabbdom.VNode>
Note that there are 2 function signatures, this is because select
is curried!
This is the main function provided by this library, it allows using a css selector to find vNode's that are made from that css selector. The vNode used will be traversed, and any matches at any arbitrary depth will be returned inside of the resulting array. An empty array will be returned if no matches are found.
import { select } from 'snabbdom-selector'
const vNode = h('div', {}, [
h('div.test', {}, [
h('p', {key: 1}, 'Foo')
])
])
const match = select('.test p'); // if given 1 parameter it returns a new function!
const matches = match(vNode);
console.log(matches)
// => [{sel: 'p', text: 'Foo', elm: HTMLElement, key: 1, children: undefined, data: {...}}]
selectorParser(selector: string): Object
This function given a CSS selector like that passed to snabbdom's h
function, returns an object
containing parsed tagName, id, and className.
import { selectorParser } from 'snabbdom-selector'
const { tagName, id, className } = selectorParser('div#foo.bar.baz');
console.log(tagName) // div
console.log(id) // foo
console.log(className) // 'bar baz'
classNameFromVNode(vNode: snabbdom.VNode): string
This function given a snabbdom VNode object will return its className including that contained
within snabbdom's provided props
and class
modules.
import { classNameFromVNode } from 'snabbdom-selector'
const vNode = h('div.foo', { class: { bar: true } }, [])
console.log(classNameFromVNode(vNode)) // 'foo bar'
This library uses compatible versioning, a versioning system that is backwards compatible with semantic-versioning.
FAQs
Snabbdom CSS-Selector
We found that snabbdom-selector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.